{extend name="layouts@base" /}
{block name="head"}
<link rel="stylesheet" href="__STATIC__/mobile/default/css/login.css" />
<!--<link rel="stylesheet" href="__STATIC__/mobile/default/css/myaddress.css?v=2">-->
<link rel="stylesheet" href="__STATIC__/mobile/default/css/cityPicker.css">
<link rel="stylesheet" href="__STATIC__/mobile/default/css/userData.css" />
{/block}
{block name="main" }
    <div class="page-bd">
   <!-- 页面内容-->
        <div class="top">
          <img src="__STATIC__/mobile/default/images/APPLOGO.png" alt="">
          <span class="fs34 color_3 fw_b">{:settings('shop_title')}</span>
        </div>
        <div class="inputBlock bor_b">
            <img src="__STATIC__/mobile/default/images/register03.png" alt="" class="imgIcon">
            <input type="text" class="fs32 fw_b textBox" id="mobile" placeholder="手机号">
        </div>
        {if condition="$sms_fun['register']==1"}
        <div class="inputBlock bor_b">
          <img src="__STATIC__/mobile/default/images/register04.png" alt="" class="imgIcon">
              <input type="text" class="fs32 fw_b textBox code" id="code" placeholder="验证码">
              <div class="codeBox">
                  <input type="text" value="获取验证码" id="codebtn" class="color_r fs28 fw_b" readonly onclick="codeButton()">
              </div>
        </div>
        {/if}

<!--        <div class="inputBlock bor_b cell_access">-->
<!--                <img src="__STATIC__/mobile/default/images/register05.png" alt="" class="imgIcon">-->
<!--                <input type="text" value=""  placeholder="请选择地区" class="fs34 fw_b color_3 bankBox add_address" readonly="" id="city-picker" data-code="" data-codes="">-->
<!--        </div>-->

        <div class="inputBlock bor_b">
            <img src="__STATIC__/mobile/default/images/register05.png" alt="" class="imgIcon">
            <input type="text" class="fs34 fw_b textBox" id="pid" placeholder="邀请码">
        </div>

        <div class="inputBlock bor_b">
          <img src="__STATIC__/mobile/default/images/register05.png" alt="" class="imgIcon">
            <input type="text" class="fs34 fw_b textBox" id="nick_name" placeholder="昵称">
        </div>

        <div class="inputBlock bor_b">
        <img src="__STATIC__/mobile/default/images/register02.png" alt="" class="imgIcon">
              <input type="password" class="fs38 fw_b textBox" id="password" placeholder="密码">
              <div class="ereBox">
                  <img src="__STATIC__/mobile/default/images/login01.png" alt="" data-type="0">
              </div>
        </div>
        <div class="rulesBox">
            <label for="isAgree">
                <div class="iconBox">
                  <input type="checkbox" class="check" name="checkbox1" id="isAgree" value="1">
                  <i class="icon_checked"></i>
                </div>
            </label>
            <div class="rules fs26 color_9">我同意<a href="{:url('shop/article/registerAgreement')}" class="color_3">《{:settings('shop_title')}》注册协议</a></div>
        </div>

        <div class="loginbutton fs32 fw_b color_w BGcolor_r register">注册</div>
        <div class="fs30 goregister"><span class="color_9">已有账号，</span><a href="{:url('login')}" class="fw_b color_3">立即登录</a></div>
      </div>
{/block}
{block name="footer"}
<script src="__STATIC__/js/jquery/jquery-weui.min.js"></script>
 <script>
     // $(document).on('click','.add_address', function () {
     //     $("#city-picker").cityPicker({
     //         title: "请选择省市区"
     //     });
     // })
    $(function(){

      $('.ereBox').on('click',function(){
        var obj=$(this).find('img')
        if(obj.attr('data-type')=='0'){
          obj.attr('src','__STATIC__/mobile/default/images/login02.png')
          obj.attr('data-type','1')
          $(this).siblings('input').attr('type','text')
        }else{
          obj.attr('src','__STATIC__/mobile/default/images/login01.png')
          obj.attr('data-type','0')
          $(this).siblings('input').attr('type','password')
        }
      })
    })
    $('.register').on('click',function(){
        var arr = new Object();
        arr.mobile = $('#mobile').val();
        arr.nick_name = $('#nick_name').val();
        arr.password = $('#password').val();
        arr.pid = $('#pid').val();
        arr.regionIds = $(document).find('#city-picker').data('codes');
        if (arr.mobile == ''){
            _alert('请输入手机号码.');
            return false;
        }

        if ($('#code').length > 0){
            arr.code = $('#code').val();

            if (arr.code == ''){
                _alert('请输入验证码..');
                return false;
            }
        }
        if (arr.nick_name == ''){
            _alert('请输入用户昵称.');
            return false;
        }
        if (arr.password == '' ){
            _alert('请输入用户密码.');
            return false;
        }
        if (arr.password.length < 8){
            _alert('用户密码长度不能小于八位.');
            return false;
        }
        if ($('#isAgree').is(':checked') == false){
            _alert('请查看后并勾选同意注册协议..');
            return false;
        }
        jq_ajax('{:url("member/api.passport/register")}',arr,function (res) {
            if (res.code == 0) {
                _alert(res.msg);
                return false;
            }
            _alert(res.msg,'{:url("login")}');
        })
    })
  function codeButton(){
        var arr = new Object();
        arr.type = 'register';
        arr.mobile = $('#mobile').val();
        if (arr.mobile == ''){
            _alert('请输入手机号码');
            return false;
        }
        jq_ajax('{:url("publics/api.sms/sendCode")}',arr,function (res) {
            if (res.code == 0){
                _alert(res.msg);
                return false;
            }
            var codebtn = $("#codebtn");
            setTimeout(function(){
                codebtn.css("color","#999");
                codebtn.attr("disabled","disabled");
            },1000)
            var time = 60;
            var set=setInterval(function(){
                codebtn.val(""+--time+"s");
            }, 1000);
            setTimeout(function(){
                codebtn.attr("disabled",false).val("获取验证码");
                codebtn.css("color","#F65236");
                clearInterval(set);
            }, 60000);
        })

  }
    </script>
{/block}
